import { $fetch } from '@/settings/utils/fetch';

export const uploadImage = async (url: string) => {
  if (url.indexOf('http') === 0 && !/^https:\/\/.+?\.oafimg\.cn\//g.test(url)) {
    const { isSuccess, data } = await $fetch('/admin/oss/getOssPathByUrl', {
      data: {
        url,
      },
    });

    if (isSuccess) {
      url = data;
    }
  }

  return url;
};
